import Vue from 'vue'
import OssProvider from '@/utils/ossProvider'
import { OSS_DIRS } from '@/data/basic_data'

Vue.mixin({
  data() {
    return {
      ossLastImgUrl: ''
    }
  },
  computed: {
    ossUploader: () => new OssProvider()
  },
  methods: {
    async customizeUpload({ file }) {
      this.ossLastImgUrl = await this.ossUploader.upload(file, OSS_DIRS.IMAGE)
    },
    async customizeUploadVideo({ file }) {
      this.ossLastImgUrl = await this.ossUploader.upload(file, OSS_DIRS.VIDEO)
    },
    async customizeUploadAudio({ file }) {
      this.ossLastImgUrl = await this.ossUploader.upload(file, OSS_DIRS.VOICE)
    }
  }
})
